#define _CRT_SECURE_NO_WARNINGS

#include"stack.h"

bool isValid(char* s)
{
    stack brackets;
    StackInit(&brackets);

    if (*s == '}' || *s == ']' || *s == ')')
        return false;

    while (*s)
    {
        if (*s == '{'
            || *s == '('
            || *s == '[')
        {
            StackPush(&brackets, *s);
        }
        else {
            char a = StackTop(&brackets);
            if (a == '{' && *s != '}'
                || a == '(' && *s != ')'
                || a == '[' && *s != ']')
            {
                return false;
            }

            StackPop(&brackets);
        }
        s++;

    }
    return true;
}
//
//
//void print(char* p)
//{
//    while (*p++)
//    {
//        printf("%c", *p);
//    }
//}

int main()
{
    char arr[] = "{{[[]]}}()";
    //print(arr);
    isValid(arr);
	return 0;
}